<template>
  <HomePanel title="人气推荐" subTitle="人气爆款 不容错过" ref="target">
    <template v-slot:right>
      <!--      <XtxMore />-->
    </template>
    <template v-slot:default>
      <Transition name="fade">
        <ul class="goods-list" v-if="goods">
          <li v-for="item in goods" :key="item.id">
            <RouterLink to="/">
              <img :src="item.picture" alt="" />
              <p class="name ellipsis">{{ item.name }}</p>
              <p class="title">{{ item.title }}</p>
              <p class="alt">{{ item.alt }}</p>
            </RouterLink>
          </li>
        </ul>
        <HomeSkeleton v-else />
      </Transition>
    </template>
  </HomePanel>
</template>
<script>
import HomePanel from "@/views/Home/components/HomePanel";
import { getHotGoods } from "@/api/home";
import useLazeData from "@/hooks/useLazyData";
import HomeSkeleton from "@/views/Home/components/HomeSkeleton";
export default {
  name: "HomeHot",
  components: { HomeSkeleton, HomePanel },
  setup() {
    // 数据懒加载
    const { result, target } = useLazeData(getHotGoods);
    return {
      goods: result,
      target,
    };

    // const goods = ref([]);
    // getHotGoods().then((data) => {
    //   goods.value = data.result;
    // });
    // return {
    //   goods,
    // };
  },
};
</script>
<style scoped lang="less">
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
    .hoverShadow();
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding: 12px 30px 0 30px;
      text-align: center;
    }
    .price {
      color: @priceColor;
    }
    .alt {
      color: #999;
      font-size: 18px;
    }
  }
}
</style>
